package com.qidian.tcba.admin.api.controller;


import com.qidian.tcba.admin.model.dto.auditRecord.AuditRecordDTO;
import com.qidian.tcba.admin.model.dto.recordProcess.AuditRecordDetailsDTO;
import com.qidian.tcba.admin.service.ParkLotRecordAuditRecordService;
import com.qidian.tcba.utils.result.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 停车场备案审核记录表 前端控制器
 * </p>
 *
 * @author 冯永龙
 * @since 2021-07-06
 */
@RestController
@RequestMapping("/parkLotRecordAuditRecord")
@Api(tags ="审核")
public class ParkLotRecordAuditRecordController {

    private final ParkLotRecordAuditRecordService parkLotRecordAuditRecordService;

    public ParkLotRecordAuditRecordController(ParkLotRecordAuditRecordService parkLotRecordAuditRecordService) {
        this.parkLotRecordAuditRecordService = parkLotRecordAuditRecordService;
    }

    @ApiOperation("获取审核记录")
    @GetMapping("/getAuditRecords/{processHistoryId}")
    public JsonResult getAuditRecordDetails(@PathVariable("processHistoryId") int processHistoryId){
        List<AuditRecordDetailsDTO> auditRecordDetails = parkLotRecordAuditRecordService.getAuditRecordDetails(processHistoryId);
        return JsonResult.success().data("rows",auditRecordDetails);
    }

    @ApiOperation("审核")
    @PostMapping("/submitAuditRecord")
    public JsonResult submitAuditRecord(@RequestBody AuditRecordDTO auditRecordDTO){
        parkLotRecordAuditRecordService.submitAuditRecordDetails(auditRecordDTO);
        return JsonResult.success();
    }
}

